package frame.laxcen.response;

import frame.laxcen.BaseFrame;
import frame.laxcen.dataobject.DataObject_0001_01;
import frame.laxcen.dataobject.DataObject_0010_0E;
import frame.laxcen.exception.IllegalFrameFormatException;
import frame.laxcen.response.annotation.FrameFeature;
import frame.laxcen.util.FrameReader;

import java.util.HashMap;
import java.util.Map;

// 返回读写器自动空闲模式
@FrameFeature(MessageType = 0b0010, Mid = 0x0E)
public class Response_0010_0E extends BaseResponse {

    public Response_0010_0E(BaseFrame baseFrame) throws IllegalFrameFormatException {

        super(baseFrame);

        getContentMap().putAll(explainToMap());
    }

    @Override
    protected Map<String, String> analyzeResponse(FrameReader reader) throws IllegalFrameFormatException {

        Map<String, String> result = new HashMap<>();

        // 自动空闲模式使能

        switch(reader.readU8()) {

            case 0: result.put("自动空闲模式使能", "关"); break;

            case 1: result.put("自动空闲模式使能", "开"); break;
        }

        // 自动空闲时间

        int time = reader.readU16();

        result.put("自动空闲时间", "" + time);

        return result;
    }

    public DataObject_0010_0E getDataObject() {

        return new DataObject_0010_0E(getContentMap());
    }
}
